<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<link rel="stylesheet" href="/JoyniProjectManage/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<title>JOY</title>
	</head>
	<body>
	
	<div class="zTreeDemoBackground left">
		<ul id="tree" class="ztree"></ul>
	</div>
	
	<input type="button" id="btn" value="统计"/>
	<script src="/JoyniProjectManage/js/common/config.js" type="text/javascript"></script>
	<script src="/JoyniProjectManage/js/jquery/jquery-1.8.3.min.js" type="text/javascript"></script>
	<script src="/JoyniProjectManage/js/jquery/jquery.ztree.all-3.5.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		var setting = {
			async: {
				enable: true,
				url:config.baseURL + "userTree/find",
				autoParam:["id=pid"],
				dataFilter: filter,
				type: "get"
			},
			check: {
				enable: true
			}
		};
		
		function filter(treeId, parentNode, childNodes) {
			if (!childNodes) return null;
			for (var i=0, l=childNodes.length; i<l; i++) {
				childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
			}
			return childNodes;
		}

		$(document).ready(function(){
			$.fn.zTree.init($("#tree"), setting);
			$("#btn").click(function() {
				$.each($.fn.zTree.getZTreeObj("tree").getCheckedNodes(true), function(n, val) {
					alert(this.name);
				});
			});
		});
	</script>
	</body>
</html>